package pong.mathematic;

public class TempVector2D {
	public float x;
	public float y;
	public float restoreAngle;

	public TempVector2D(float x, float y) {
		this.x = x;
		this.y = y;
		this.restoreAngle = 0.0f;
	}

	public float angle() {
		return (float) Math.atan2(y, x);
	}

	public float mag() {
		return (float) Math.sqrt((x * x) + (y * y));
	}

	public void rotateCoordinates(float tiltAngle) {
		this.restoreAngle += tiltAngle;
		float angle = angle();
		float mag = mag();
		angle -= tiltAngle;
		x = mag * (float) Math.cos(angle);
		y = mag * (float) Math.sin(angle);
	}

	public void restoreCoordinates() {
		float angle = angle();
		float mag = mag();
		angle += restoreAngle;
		x = mag * (float) Math.cos(angle);
		y = mag * (float) Math.sin(angle);
		restoreAngle = 0.0f;
	}
}
